package ModelLayer;
import java.util.ArrayList;
public class Order 
{
	private int orderNO;
	private static int orderCount = 10100;
//	private Customer customer;
//	private Salesman salesman;
	private ArrayList<PartOrder> partOrders;
	private double totalPrice;
	private String orderDate;

	public Order(String orderDate)
	{
		this.orderDate = orderDate;
		this.totalPrice = 0;
		partOrders = new ArrayList<PartOrder>();
		orderNO = calculateOrderNO();
	}
	
	public Order()
	{
		orderNO = calculateOrderNO();
		partOrders = new ArrayList<PartOrder>();
	}
	
	public int calculateOrderNO()
	{
		orderCount++;
		return orderCount;
	}
	
	public double calculateTotalPrice()
	{
		double totalPrice = 0;
		for(PartOrder partOrder : partOrders)
		{
			totalPrice += partOrder.getPartOrderPrice();
		}
		return totalPrice;
	}
	
	public void addPartOrder(PartOrder partOrder)
	{
		if(partOrder != null)
		{
			partOrders.add(partOrder);
			totalPrice = calculateTotalPrice();
		}
	}
	
	public ArrayList<PartOrder> getPartOrders()
	{
		return partOrders;
	}

	public int getOrderNO() {
		return orderNO;
	}
	
	public void setOrderNO(int orderNO) {
		this.orderNO = orderNO;
	}
	
//	public Customer getCustomer() {
//		return customer;
//	}
//	
//	public void setCustomer(Customer customer) {
//		this.customer = customer;
//	}
//	
//	public Salesman getSalesman() {
//		return salesman;
//	}
//	
//	public void setSalesman(Salesman salesman) {
//		this.salesman = salesman;
//	}
	
	public double getTotalPrice() {
		calculateTotalPrice();
		return totalPrice;
	}
	
	public void setTotalPrice(double totalPrice) {
		this.totalPrice = totalPrice;
	}
	
	public String getOrderDate() {
		return orderDate;
	}
	
	public void setOrderDate(String orderDate) {
		this.orderDate = orderDate;
	}
}
